// startYear startMonth
import { splitToLength, BoolStrWithBoolen } from '../../../Utils/common'
const presentIllnessHistory = function (data) {}

export function sub1(data) {
  console.log('************in convertWithSub1************')
  const {
    attr9,
    attr10,
    attr11,
    attr12,
    wheezingTimesUntilNow,
    attr13,
    wheezingTimesPastYear,
    attr14,
    wheezingTimeLastThreeMonths,
    attr15,
    wheezingContinuedDays,
    attr16,
    attr17,
    attr18,
    attr19,
    attr20,
    attr21,
    relieveCoughAsthmaTimes,
    attr22,
    attr23,
    attr24,
    attr25,
  } = data

  const {
    attr26,
    attr27,
    attr28,
    attr29,
    attr30,
    attr31,
    attr32,
    attr33,
    attr34,
  } = data
  if (!attr11) {
    return ''
  }
  let str = ''
  if (attr9 || attr10) {
    str += '患儿自'
    if (attr9) str += `${attr9}年`
    if (attr10) str += `${attr10}月`
    if (attr11) str += `开始出现${attr11Convert(attr11)}`
  } else {
    str += `${attr11Convert(attr11)}`
  }

  if (attr12 || wheezingTimesUntilNow) {
    str += '。至今共'
    if (attr12) str += `发作咳嗽${attr12}次`
    if (wheezingTimesUntilNow)
      str += (attr12 ? '，' : '') + `发作喘息${wheezingTimesUntilNow}次`
  }

  if (attr13 || wheezingTimesPastYear) {
    str += '，过去1年共'
    if (attr13) str += `发作咳嗽${attr13}次`
    if (wheezingTimesPastYear)
      str += (attr13 ? '，' : '') + `发作喘息${wheezingTimesPastYear}次`
  }

  if (attr14 || wheezingTimeLastThreeMonths) {
    str += '，近3个月共'
    if (attr14) str += `发作咳嗽${attr14}次`
    if (wheezingTimeLastThreeMonths)
      str += (attr14 ? '，' : '') + `发作喘息${wheezingTimeLastThreeMonths}次`
  }

  if (attr15 || wheezingContinuedDays) {
    str += '，每次发作症状迁延时间'
    if (attr15) str += `咳嗽${attr15}天`
    if (wheezingContinuedDays)
      str += (attr15 ? '，' : '') + `发作喘息${wheezingContinuedDays}天`
  }

  if (attr16)
    str += `，${
      BoolStrWithBoolen(attr16) ? '有' : '无'
    }使用全身糖皮质激素、急诊、住院的急性发作经历`
  if (attr16 && attr17) str += `，这种严重发作曾在6个月内发作${attr17}次。`
  if (attr18)
    str += `，${BoolStrWithBoolen(attr18) ? '' : '不是'}每周有症状并需要治疗`
  console.log('attr19to20')
  str += attr19to20(attr19, attr20)

  if (attr21 || relieveCoughAsthmaTimes) {
    str += '，过去4周需要使用药物'
    if (attr21) str += `缓解咳嗽总有${attr21}次`
    if (relieveCoughAsthmaTimes)
      str += (attr21 ? '，' : '') + `缓解咳喘症状${relieveCoughAsthmaTimes}次`
  }

  if (attr22) str += `，近${attr22}天再次出现`

  str += attr23to25Convert(attr23, attr24, attr25)

  if (attr26) str += `。${attr26}发热`
  if (attr27) str += `，体温${attr27}°C`
  if (attr28) str += `，${attr28}流鼻涕`

  str += attr29to30Convert(attr29, attr30)

  str += attr31to33Convert(attr31, attr32, attr33)
  if (attr34) str = str + '。其他：' + attr34
  console.log('************convertWithSub1-1 out************************')
  return str
}
function attr11Convert(str = '') {
  if (splitToLength(str, 2)) {
    return '反复咳嗽伴喘息发作'
  } else {
    const cough = str.includes('反复咳嗽') ? '反复咳嗽发作' : ''
    const wheezing = str.includes('伴喘息') ? '反复喘息发作' : ''
    return cough || wheezing
  }
}
// 是否使用抗生素
function attr31to33Convert(attr31, attr32, attr33) {
  if (BoolStrWithBoolen(attr31) && BoolStrWithBoolen(attr33) && attr32) {
    return `，最近一次发作使用抗生素治疗了${attr32}天，症状有所缓解。`
  } else if (BoolStrWithBoolen(attr31) === false && BoolStrWithBoolen(attr33)) {
    return '，最近一次发作沒有使用抗生素治疗，但症状有所缓解。'
  } else if (
    BoolStrWithBoolen(attr31) &&
    attr32 &&
    BoolStrWithBoolen(attr33) === false
  ) {
    return `，最近一次发作使用抗生素治疗了${attr32}天，症状没有缓解。`
  } else if (BoolStrWithBoolen(attr31) === false) {
    return '，最近一次发作沒有使用抗生素治疗。'
  } else if (BoolStrWithBoolen(attr31)) {
    return '，最近一次发作使用抗生素治疗。'
  }
  return ''
}
function attr29to30Convert(attr29, attr30) {
  if (BoolStrWithBoolen(attr29) && attr30) {
    return `，喘息之前有吃${attr30}呛过。`
  } else if (BoolStrWithBoolen(attr29)) {
    return '，喘息之前有吃过东西呛过。'
  } else if (BoolStrWithBoolen(attr29) !== '') {
    return '，没有吃东西呛过。'
  }
  return ''
}
function attr23to25Convert(attr23, attr24, attr25) {
  if (attr23 && attr24 && attr25) {
    return `，${attr23},${attr24}${attr25 ? `(${attr25})` : ''}`
  } else if (attr24 && attr25) {
    return `，${attr24}${attr25 ? `(${attr25})` : ''}`
  } else if (attr23) {
    return attr23
  } else if (attr24) {
    return attr24
  }

  return ''
}

function attr19to20(attr19, attr20) {
  if (attr19 && attr20) {
    return `，过去4周共有咳嗽${attr19}天/喘息发作${attr20}次`
  } else if (attr19) {
    return `，过去4周共有咳嗽${attr19}天`
  } else if (attr20) {
    return `，过去4周共有喘息发作${attr20}次`
  }
  return ''
}
